package com.zhuzi.dto.jc;

import com.zhuzi.common.utils.LocalDateTimeUtils;
import lombok.Data;

import java.util.List;

/**
 * @author zhuzi
 * 2022/9/8 17:08
 * 巨潮搜索DTO
 */
@Data
public class SearchResultDTO {

    private final static String BASE_URL = "http://static.cninfo.com.cn/";
    private String classifiedAnnouncements;
    private int totalSecurities;
    private int totalAnnouncement;
    private int totalRecordNum;
    private List<Announcements> announcements;
    private String categoryList;
    private boolean hasMore;
    private int totalpages;

    /**
     * <a href="https://img-blog.csdnimg.cn/1e2e4328ae5b49809c056f96aa461de2.png">详细字段</a>
     */
    @Data
    public static class Announcements {
        /**
         * 数据id 都是null
         */
        private String id;

        /**
         * 股票-代码
         */
        private String secCode;
        /**
         * 股票-简称
         */
        private String secName;
        private String orgId;
        /**
         * 新闻ID
         */
        private String announcementId;
        /**
         * 新闻标题
         */
        private String announcementTitle;
        private long announcementTime;
        /**
         * 新闻URL
         */
        private String adjunctUrl;
        /**
         * 文件大小
         */
        private int adjunctSize;
        /**
         * 文件类型
         */
        private String adjunctType;
        /**
         * 为NULL
         */
        private String storageTime;
        private String columnId;
        private String pageColumn;
        private String announcementType;
        private String associateAnnouncement;
        private String important;
        private String batchNum;
        private String announcementContent;
        private String orgName;
        private String announcementTypeName;

        public String toDingMsg() {
            return String.format("%s\n%s\n\n", secCode + secName + ":" + LocalDateTimeUtils.convert(announcementTime),
                    BASE_URL + adjunctUrl
            );
        }
    }
}
